import http from '@/utils/http';

/**
 * 获取区域树
 * @param params
 * @returns {*|Promise<any>}
 */
export const categoryTreeSelectData = (params?: any) => {
 
  return http.get('bus/evaluation/treeSelectData?' + Math.floor(Math.random() *1000), {params});
}

export const leafTreeSelectData = (params?: any) => {
  return http.get('bus/evaluation/leafTreeSelectData?' + Math.floor(Math.random() *1000), {params});
}


/**
 * 获取区域树型表格数据
 * @param params
 * @returns {*|Promise<any>}
 */
export const getCategoryTreeTableData = (params: any = {}) => {
  return http.get('bus/evaluation/treeTableData', {params});
}

/**
 * 删除区域信息
 * @param params
 * @returns {*|Promise<any>}
 */
export const removeCategory = (params: any) => {
  return http.delete('bus/evaluation/remove', {params});
}

/**
 * 保存修改区域信息
 * @param params
 * @returns {*|Promise<any>}
 */
export const updateCategory = (params: any) => {
  return http.put('bus/evaluation/edit', params);
}


/**
 * 保存修改区域信息
 * @param params
 * @returns {*|Promise<any>}
 */
export const updateContent = (params: any) => {
  return http.put('bus/evaluation/updateContent', params);
}

/**
 * 保存新增区域信息
 * @param params
 * @returns {*|Promise<any>}
 */
export const addCategory = (params: any) => {
  return http.post('bus/evaluation/add', params);
}

/**
 * 通过id获取区域信息
 * @param params
 * @returns {*|Promise<any>}
 */
export const getById = (params: any) => {
  return http.get('bus/evaluation/' + params.id);
}

/**
 * 验证区域名称是否唯一
 * @param params
 * @returns {*|Promise<any>}
 */
export const checkCategoryNameUnique = (params: any) => {
  params.loading = false;
  return http.post('bus/evaluation/checkNameUnique', params);
}

